import apiService from '@/api/util/apiService';
import SM3 from 'sm3';

const loginService = {
    getCheckCode() {
        let url = '/login/getCheckCode';
        return apiService.asynchronousStandardCall('GET', url, {});
    },

    login(loginData) {
        let _data = {
            user: loginData.user,
            pwd: SM3(loginData.pwd),
            captchaSession: sessionStorage.getItem("captcha_session"),
            captcha: loginData.captcha,
        };
        let url = "/login/login";
        return apiService.asynchronousStandardCall("POST", url, _data);
    },

    checkSession(){
        let url = '/login/checkSession';
        return apiService.asynchronousStandardCall("GET", url, {});
    },

    logout(){
        let url = "/login/logout";
        return apiService.asynchronousStandardCall("GET", url, {});
    }
}

export default loginService